<template>
  <div>
    <el-select v-model="selectleibie" placeholder="请选择类型">
      <el-option
        v-for="item in leibies"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
export default {
  props: ["shujus"],
  data() {
    return {
      leibies: [],
      selectleibie: "",
    };
  },
  methods: {
    // 更新leibies
    genxinleibies(newleibies) {
      if (newleibies.length != 0) {
        this.leibies = newleibies;
        this.selectleibie = this.leibies[0].value;
      }else{
        this.leibies = [];
        this.selectleibie = "该村未设置类别";
      }
    },
  },
  watch: {
    // 因为好多类别都是用这个组件    所以把默认选中的放在第一个
    selectleibie: {
      handler: function () {
        this.$emit("selectleibiefangfa", this.selectleibie);
      },
    },
  },
  created() {
    if (this.shujus.length !== 0) {
      this.leibies = this.shujus;
      this.selectleibie = this.shujus[0].value;
    }
  },
};
</script>

<style lang="less" scoped>
</style>